<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <h1>我的页面一</h1>
    <button class="btn">点我跳转到页面二并传参</button>
  </body>
</html>
<script>
  var obj = {
    name: "zhangsan",
    age: 20,
  };
  document.getElementsByClassName("btn")[0].onclick = function () {
    window.location.href = `./a.html?name=${obj.name}&age=${obj.age}`;
  };
</script>
